import string
from sqlalchemy import Column,ForeignKey,Integer,String
from sqlalchemy.orm import relationship

from database import Base

class User(Base):
    __tablename__="users"

    user_id=Column(Integer,primary_key=True,index=True)
    phone=Column(String,unique=True,index=True)
    nickName=Column(String,index=True)
    password=Column(String,index=True)

    roomInfo=relationship("RoomInfo",back_populates="owner")

class RoomInfo(Base):
    __tablename__="roomInfo"

    rid=Column(Integer,primary_key=True,index=True)
    roomName=Column(String,index=True)
    idCard=Column(String,index=True)
    personName=Column(String,index=True)
    phone=Column(String,index=True)
    waterNumber=Column(String,index=True)
    electricNumber=Column(String,index=True)
    moveInDate=Column(String,index=True)
    modifyDate=Column(String,index=True)

    owner_id=Column(Integer,ForeignKey("users.user_id"))

    owner=relationship("User",back_populates="roomInfo")  